/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.braincasedesigns.roller.model;

import com.braincasedesigns.roller.model.Die;
import com.braincasedesigns.roller.model.Face;
import java.awt.Image;
import java.util.Random;

/**
 *
 * @author jcampbel
 */
public class FudgeDie implements Die {

    private static final Random random = new Random();

    
    public FudgeDie(){
        
    }
    
    public int getFaces() {
        return FudgeFace.values().length;
    }

    public int getIndex(Face f) throws IllegalArgumentException {
        FudgeFace[] faces = FudgeFace.values();
        int idx = -1;
        for (int i = 0; i < faces.length; i++) {
            FudgeFace face = faces[i];
            if (face.equals(f)) {
                idx = i;
                break;
            }
        }
        return idx;
    }

    public Face getFace(int idx) throws IllegalArgumentException {
        FudgeFace[] faces = FudgeFace.values();
        if (idx < 0 || idx >= faces.length) {
            throw new IllegalArgumentException("Invalid index.");
        }

        return faces[idx];
    }

    public int add(int idx, int val) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Face add(Face f, int val) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public Face roll() {
        FudgeFace[] faces = FudgeFace.values();
        return faces[random.nextInt(faces.length)];
    }

    public String getNotation() {
        return "dF";
    }

    public enum FudgeFace implements Face {

        MINUS("-", -1),
        BLANK("B", 0),
        PLUS("+", 1);
        private final String symbol;
        private final int value;

        private FudgeFace(String s, int i) {
            this.symbol = s;
            this.value = i;
        }

        public String getStringRepresentation() {
            return symbol;
        }

        public int getNumericRepresentation() {
            return value;
        }

        public Image getImageRepresentation() {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }
}
